package com.kd.eb.controller;

import com.kd.eb.model.EbUser;
import com.kd.eb.service.LoginService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
public class LoginController {
    @RequestMapping("/to_login")
    public String toLogin(){
        return "login";
    }

    @Resource
    private LoginService loginService;
    @RequestMapping("/login")
    public String login(EbUser ebUser, HttpServletRequest request){
        EbUser lgnUser = loginService.login(ebUser);
        request.getSession().setAttribute("lgnUser",lgnUser);
        return "redirect:/index/index";
    }

}
